package com.mycompany.app;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.DeclareParents;
import org.springframework.stereotype.Component;

@Component("countingAspect")
@Aspect
public class Countable {


	@DeclareParents(value = "com.mycompany.app.*Service", defaultImpl = DefaultUsageTracked.class)
	public static UsageTracked mixin;

	@Before("execution(public * com.mycompany.app.*Service.*(..)) &&"
			+ "this(usageTracked)")
	public void recordUsage(UsageTracked usageTracked) {
		usageTracked.incrementUseCount();
	}
}
